<template>
    <Container class="coupon-add">
      <div class="container-header title title-center" slot="header">新建优惠券
        <Button size="large" class="fl btn-back"  icon="ios-arrow-back" @click="jumpPage">返回</Button>
      </div>
      <!-- 基础设置 -->
      <DefaultEditItem ref="default" @complete="onChangeType" @changeBtn="changeBtn"></DefaultEditItem>
      <div class="container-footer bg-white" slot="footer">
        <Button type="primary" size="large" class="ml" @click="onClickNext" v-if="showNext" :disabled="disabled">下一步</Button>
        <Button type="primary" size="large" class="ml" @click="onSave" :disabled="disabled" v-else>保存</Button>         
      </div>
    </Container>
</template>
<script>
import DefaultEditItem from './edit/DefaultEditItem'
export default {
  components: {
    DefaultEditItem
  },
  data () {
    return {
      showNext: true,
      disabled: false
    }
  },
  methods: {
    changeBtn(boo) {
      this.disabled = boo
    },
    onClickNext() {
      this.$refs.default.postData(1)
    },
    onChangeType(value) {
      this.showNext = value === '1'
    },
    onSave() {
      this.$refs.default.postData(2)
    },
    jumpPage() {
      // this.$router.push({
      //   name: 'sales/coupon/list'
      // })
      this.$router.back()
    }
  }
}
</script>
